from pydantic import BaseModel
from typing import List, Optional, Dict, Any
from datetime import datetime

class IFCElement(BaseModel):
    type: str
    global_id: str
    name: Optional[str] = None
    object_type: Optional[str] = None
    properties: Optional[Dict[str, Any]] = None

class IFCProjectInfo(BaseModel):
    name: Optional[str] = None
    description: Optional[str] = None
    object_type: Optional[str] = None

class IFCConversionResponse(BaseModel):
    status: str
    message: str
    data: Dict[str, Any]
    file_name: Optional[str] = None
    conversion_time: datetime

class ErrorResponse(BaseModel):
    status: str = "error"
    message: str
    details: Optional[str] = None

# 平台专用模型
class UploadRequest(BaseModel):
    building_type: str = "commercial"
    project_name: Optional[str] = None

class UploadResponse(BaseModel):
    upload_id: str
    status: str
    message: str
    file_name: str
    file_size: int
    upload_time: datetime
    analysis_url: str
    progress: int = 0

class AnalysisResult(BaseModel):
    upload_id: str
    overall_score: float
    risk_level: str
    summary: str
    findings: List[Dict[str, Any]]
    recommendations: List[str]
    cost_estimate: Dict[str, float]
    timeline_estimate: Dict[str, int]
    detailed_report: Optional[Dict[str, Any]] = None

class Finding(BaseModel):
    id: str
    category: str
    severity: str
    title: str
    description: str
    location: Optional[str] = None
    cost_impact: Optional[float] = None
    timeline_impact: Optional[int] = None
    suggested_fix: Optional[str] = None